package com.github.data_manage

import com.github.data_manage.controller.InvestmentsController
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.mock.web.MockMultipartFile
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.time.measureTime

/**
 * @author chenhainan
 * @since 2024-09-07 15:01
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class InvestmentsTests {

    @Autowired
    lateinit var investmentsController: InvestmentsController


    @Test
    fun importInvestments() {
        Files.newInputStream(Paths.get("/Users/chenhainan/Downloads/投资案例信息导入.xlsx")).use { fis ->
            val mockMultipartFile = MockMultipartFile("excelFile",fis)
            val time = measureTime {
                investmentsController.importTemplate(mockMultipartFile)
            }
            println(time)
        }
    }
}